home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / nslookup / RCS / commands.l,v < prev    next >
Encoding:
Text File  |  1988-11-27  |  4.8 KB  |  196 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     88.11.23.13.39.29;  author douglis;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @original src from monet.
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @%{
  27.  
  28. /*
  29.  * Copyright (c) 1985 Regents of the University of California.
  30.  * All rights reserved.
  31.  *
  32.  * Redistribution and use in source and binary forms are permitted
  33.  * provided that the above copyright notice and this paragraph are
  34.  * duplicated in all such forms and that any documentation,
  35.  * advertising materials, and other materials related to such
  36.  * distribution and use acknowledge that the software was developed
  37.  * by the University of California, Berkeley.  The name of the
  38.  * University may not be used to endorse or promote products derived
  39.  * from this software without specific prior written permission.
  40.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  41.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  42.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  43.  *
  44.  *    @@(#)commands.l    5.9 (Berkeley) 6/18/88
  45.  */
  46.  
  47. /*
  48.  *******************************************************************************
  49.  *
  50.  *  commands.l
  51.  *
  52.  *      Andrew Cherenson     CS298-26  Fall 1985
  53.  *
  54.  *    Lex input file for the nslookup program command interpreter.
  55.  *    When a sequence is recognized, the associated action
  56.  *    routine is called. The action routine may need to
  57.  *    parse the string for additional information.
  58.  *
  59.  *  Recognized commands: (identifiers are shown in uppercase)
  60.  *
  61.  *    server NAME    - set default server to NAME, using default server
  62.  *    lserver NAME    - set default server to NAME, using initial server
  63.  *    finger [NAME]    - finger the optional NAME
  64.  *    exit        - exit the program
  65.  *    root        - set default server to the root
  66.  *    ls NAME        - list the domain NAME
  67.  *    view FILE    - sorts and view the file with more
  68.  *    set OPTION    - set an option
  69.  *    help         - print help information
  70.  *    ?         - print help information
  71.  *    opt[ions]    - print options, current server, host
  72.  *    NAME        - print info about the host/domain NAME 
  73.  *              using default server.
  74.  *    NAME1 NAME2    - as above, but use NAME2 as server
  75.  *
  76.  *
  77.  *   yylex Results:
  78.  *    0        upon end-of-file.
  79.  *    1        after each command.
  80.  *  
  81.  *******************************************************************************
  82.  */
  83.  
  84. #include "res.h"
  85. extern char rootServerName[];
  86.  
  87. %}
  88. WS    [ \t]
  89. LET    [A-Za-z0-9.*]
  90. NAME    [A-Za-z0-9.*=_/-]
  91. %%
  92. ^{WS}*server{WS}+{LET}{NAME}*{WS}*$     { 
  93.                         /* 
  94.                          * 0 == use current server to find
  95.                          *        the new one.
  96.                          * 1 == use original server to find
  97.                          *        the new one.
  98.                          */
  99.                         SetDefaultServer(yytext, 0); 
  100.                         return(1);
  101.                     }
  102. ^{WS}*lserver{WS}+{LET}{NAME}*{WS}*$     { 
  103.                         SetDefaultServer(yytext, 1); 
  104.                         return(1);
  105.                     }
  106. ^{WS}*exit{WS}*$             { 
  107.                         return(0);
  108.                     }
  109. ^{WS}*root{WS}*$             { 
  110.                         SetDefaultServer(rootServerName, 1);
  111.                         return(1);
  112.                     }
  113. ^{WS}*finger({WS}+{LET}{NAME}*)?{WS}+>>?{WS}*{NAME}+{WS}*$     {
  114.                         /* 
  115.                          * 2nd arg. 
  116.                          *  0 == output to stdout
  117.                          *  1 == output to file
  118.                          */
  119.                         Finger(yytext, 1); 
  120.                         return(1);
  121.                     }
  122. ^{WS}*finger({WS}+{LET}{NAME}*)?{WS}*$     { 
  123.                         Finger(yytext, 0); 
  124.                         return(1);
  125.                     }
  126. ^{WS}*view{WS}+{NAME}+{WS}*$     { 
  127.                         ViewList(yytext); 
  128.                         return(1);
  129.                     }
  130. ^{WS}*ls{WS}+(("-a"|"-h"|"-m"|"-s"|"-d"){WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$    { 
  131.                           /* 
  132.                            * 2nd arg. 
  133.                            *  0 == output to stdout
  134.                          *  1 == output to file
  135.                          */
  136.                         ListHosts(yytext, 1);
  137.                         return(1);
  138.                     }
  139. ^{WS}*ls{WS}+(("-a"|"-h"|"-m"|"-s"|"-d"){WS}+)?{LET}{NAME}*{WS}*$     { 
  140.                         ListHosts(yytext, 0);
  141.                         return(1);
  142.                     }
  143. ^{WS}*set{WS}+{NAME}+{WS}*$         { 
  144.                         SetOption(yytext); 
  145.                         return(1);
  146.                     }
  147. ^{WS}*help{WS}*$             { 
  148.                         extern void PrintHelp();
  149.  
  150.                         PrintHelp();
  151.                         return(1);
  152.                     }
  153. ^{WS}*"?"{WS}*$             { 
  154.                         PrintHelp();
  155.                         return(1);
  156.                     }
  157. ^{WS}*opt(ions)?{WS}*$             { 
  158.                         ShowOptions(TRUE); 
  159.                         return(1);
  160.                     }
  161. ^{WS}*{LET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$     {
  162.                         /* 
  163.                          * 0 == output to stdout
  164.                          * 1 == output to file
  165.                          */
  166.                         LookupHost(yytext, 1); 
  167.                         return(1);
  168.                     }
  169. ^{WS}*{LET}{NAME}*{WS}*$        {
  170.                         LookupHost(yytext, 0); 
  171.                         return(1);
  172.                     }
  173. ^{WS}*{LET}{NAME}*{WS}+{LET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$     {
  174.                         /* 
  175.                          * 0 == output to stdout
  176.                          * 1 == output to file
  177.                          */
  178.                         LookupHostWithServer(yytext, 1); 
  179.                         return(1);
  180.                     }
  181. ^{WS}*{LET}{NAME}*{WS}+{LET}{NAME}*{WS}*$    {
  182.                         LookupHostWithServer(yytext, 0); 
  183.                         return(1);
  184.                     }
  185. ^{WS}*\n                { 
  186.                         return(1);
  187.                     }
  188. ^.*\n                    { 
  189.                         printf("Unrecognized command: %s", 
  190.                                 yytext); 
  191.                         return(1);
  192.                     }
  193. \n                    { ; }
  194. %%
  195. @
  196.